package com.ccjq.shosestore.core.utils;

import javax.servlet.http.HttpServletRequest;

public class PageHelper {

	
	public static PageBean getPager(HttpServletRequest request, int totalRows)
	{
		PageBean pb=new PageBean(totalRows);
		
		String currentPage=request.getParameter("currentPage");//��ǰ̨��ȡ��ǰҳ��
		System.out.println(currentPage);
		
		//���жϣ����ǵ�һ�������ҳʱ�������뷽��
		if(currentPage!=null&&!currentPage.equals(""))
		{
			pb.tiaozhuan(Integer.parseInt(currentPage));//��ת����ǰҳ��
			
			String pageMethod=request.getParameter("pageMethod");//��ȡǰ̨�����Ķ���
			
			if(pageMethod!=null)
			{
				if(pageMethod.equals("first"))
				{
					pb.First();
				}
				else if(pageMethod.equals("up"))
				{
					pb.Up();
				}
				else if(pageMethod.equals("next"))
				{
					pb.Down();
				}
				else if(pageMethod.equals("last"))
				{
					pb.last();
				}
				else if(pageMethod.equals("tiao"))
				{
					pb.tiaozhuan(Integer.parseInt(currentPage));
				}
			}
			
		}
			
		return pb;
	}
	
}

